<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        html,
        body,
        #viewDiv {
            padding: 0%;
            margin: 0%;
            height: 100%;
            width: 100%;
        }
    </style>
    <!-- <link rel="stylesheet" href="https://js.arcgis.com/4.16/esri/themes/light/main.css" /> -->
    <!-- <script src="https://js.arcgis.com/4.16/"></script> -->
    <link rel="stylesheet" href="http://localhost/4.16/esri/css/main.css" />
    <script src="http://localhost/4.16/init.js"></script>

    <script>
        require([
            "esri/Map",
            "esri/views/MapView",
            "esri/layers/VectorTileLayer",
            "esri/views/SceneView",
            "esri/layers/WMSLayer",
            "dojo/domReady!"
        ], function(Map, MapView, VectorTileLayer, SceneView, WMSLayer) {

            // //加载VectorTileLayer
            // //创建一个地图
            // var mapDemo = new Map();
            // //创建地图视图并将其绑定到地图
            // var view = new MapView({
            //     container: "viewDiv",
            //     map: mapDemo,
            //     center: [-98.5795, 39.8282],
            //     zoom: 3
            // });
            // //在地图上添加矢量图块图层,网址必须指向样式或矢量图块服务
            // var tileLayer = new VectorTileLayer({
            //     url: "http://www.fqghj.net:8887/arcgis/rest/services/YDHX/HXTEMP/MapServer/0?f=pjson"
            // });
            // mapDemo.add(tileLayer);

            // 此示例说明如何使用WMSLayer访问WMS服务并将其作为底图添加到场景中。 WMSLayer用于基于OGC Web地图服务（ WMS） 创建图层。
            // WMSLayer最初执行WMS GetCapabilities请求， 这可能需要CORS或代理页面。
            // var basemap = new basemap({
            //     baseLayers: [
            //         new WMSLayer({
            //             url: "https://ows.terrestris.de/osm/service"
            //         })
            //     ]
            // })

            var layer = new WMSLayer({
                url: "https://ows.terrestris.de/osm/service",
                sublayers: [{
                    name: "OSM-WMS"
                }]
            });
            var mapDemo = new Map({
                basemap: {
                    baseLayers: [layer]
                }
            });
            var viewDiv = new SceneView({
                container: "viewDiv",
                map: mapDemo
            });

            //https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=layers-dynamicmaplayer
        });
    </script>

</head>

<body>
    <div id="viewDiv"></div>
</body>

</html>